﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Loki.Model
{
	/// <summary>
	/// Interface for entity key mappers
	/// </summary>
	/// <typeparam name="TEntityClass"></typeparam>
	public interface IKeyMapper<TEntityClass>
	{
		/// <summary>
		/// Gets the entities corresponding to the specified value.
		/// </summary>
		/// <param name="P_Key">The key</param>
		/// <returns></returns>
		IEnumerable<TEntityClass> GetAllByKey(object P_Key);

		/// <summary>
		/// Resets the mapper.
		/// </summary>
		void Reset();

		/// <summary>
		/// Registers an entity into mapper
		/// </summary>
		/// <param name="P_Entity"></param>
		bool Register(TEntityClass P_Entity);

		/// <summary>
		/// Unregisters an entity into mapper.
		/// </summary>
		/// <param name="P_Entity">The entity</param>
		void Remove(TEntityClass P_Entity);

		/// <summary>
		/// Determines whether the specified key is loaded in mapper.
		/// </summary>
		/// <param name="P_Key">The key</param>
		/// <returns>
		/// 	<c>true</c> if the specified key is loaded; otherwise, <c>false</c>.
		/// </returns>
		bool IsLoaded(object P_Key);

		object ComputeIndex(TEntityClass P_Entity);

		/// <summary>
		/// Determines whether the specified key is invalidated.
		/// </summary>
		/// <param name="P_Key">The key.</param>
		/// <returns>
		///   <c>true</c> if the specified key is invalidated; otherwise, <c>false</c>.
		/// </returns>
		bool IsInvalidated(object P_Key);
		/// <summary>
		/// Marks the specified key as loaded in mapper
		/// </summary>
		/// <param name="P_Key">The Key</param>
		void MarkAsLoaded(object P_Key);
		/// <summary>
		/// Invalidates the loading of the specific key in mapper (partial reset)
		/// </summary>
		/// <param name="P_Key"></param>
		void Invalidate(object P_Key);
	}
}
